package com.aliyun.oss.controller;

import com.aliyun.oss.pojo.ResultObj;
import com.aliyun.oss.pojo.User;
import com.aliyun.oss.pojo.UserInfo;
import com.aliyun.oss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/reg")
    public ResultObj addUser(@RequestBody User user){
        userService.add(user);
        return ResultObj.Success();
    }
    @PostMapping("/login")
    public ResultObj userLogin(@RequestBody User user){
        UserInfo userInfo = userService.userLogin(user);
        return ResultObj.Success(userInfo);
    }

}
